package com.shm.city58;

import java.util.*;

/**
 * @author: shm
 * @dateTime: 2020/9/21 21:34
 * @description:
 */
public class Solution3 {
    /**
     * 合并数组
     * @param arrayA int整型ArrayList 数组A
     * @param arrayB int整型ArrayList 数组B
     * @return int整型ArrayList
     */
    public ArrayList<Integer> mergerArrays (ArrayList<Integer> arrayA, ArrayList<Integer> arrayB) {
        // write code here
        int size1 = arrayA.size();
        int size2 = arrayB.size();
        ArrayList<Integer> list = new ArrayList<>();
        int index1 =0,index2=0;
        while (index1<size1&&index2<size2){
            if (arrayA.get(index1)<arrayB.get(index2)){
                index1++;
            }else if (arrayA.get(index1)> arrayB.get(index2)){
                index2++;
            }else {
                list.add(arrayA.get(index1));
                index1++;
                index2++;
            }
        }
        return list;
    }
}
